package com.ctshk.rpc.order.tour.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.order.tour.dto.SeriesOrderReceiptDetailsGetInsuranceDTO;
import com.ctshk.rpc.order.tour.entity.SeriesOrderReceiptDetails;
import com.ctshk.rpc.order.tour.req.SeriesOrderReceiptDetailsGetInsuranceReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 收据明细表、每一笔收据，产生一个数据 Mapper 接口
 * </p>
 *
 * @author 谭响
 * @since 2021-02-20
 */
public interface SeriesOrderReceiptDetailsMapper extends BaseMapper<SeriesOrderReceiptDetails> {

    @SelectProvider(type = SeriesOrderReceiptDetailsProvider.class, method = "selectGetInsuranceBySelective")
    SeriesOrderReceiptDetailsGetInsuranceDTO selectGetInsuranceBySelective(@Param("req") SeriesOrderReceiptDetailsGetInsuranceReq req);

    /**
     * 批量作废订单收据详情
     * @param orderId
     * @return
     */
    @Update("DELETE FROM t_series_order_receipt_details\n" +
            "WHERE order_id = #{order_id}")
    Integer delByOrder(@Param("order_id")Long orderId);

    /**
     * 收据是否已开印花税
     * @param receiptId
     * @return
     */
    @Select("SELECT *\n" +
            "FROM t_series_order_receipt_details\n" +
            "WHERE receipt_id = #{receipt_id} AND receipt_status = 1 AND is_print = 1 AND stamp_duty_pic IS NOT NULL LIMIT 1")
    SeriesOrderReceiptDetails queryStampDutyReceipt(@Param("receipt_id") Long receiptId);
}
